//
//  FurnitureViewController.m
//  FKGW
//
//  Created by song ce on 2017/2/20.
//  Copyright © 2017年 song ce. All rights reserved.
//

#import "FurnitureViewController.h"
#import "FurnitureCollection.h"
@interface FurnitureViewController ()
@property (weak, nonatomic) IBOutlet UILabel *topView;
@property(nonatomic,strong)FurnitureCollection *furniture;
@property(nonatomic,strong)NSMutableArray *dataSoure;

@end

@implementation FurnitureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataSoure = [NSMutableArray array];
    FurnitureCollection *furniture = [[FurnitureCollection alloc]initWithFrame:CGRectMake(0, kNaviBarHeight, Main_Screen_Width, Main_Screen_Height-kNaviBarHeight)];
    [self.view addSubview:furniture];
    _furniture = furniture;
    [self searchButton];
    [self loadData];
}

-(void)searchButton{
    if(!ISNOTNEEDMESSAGEBTN){
        self.isNeedMessageItem = YES;
    }

//    UIButton *locationButton2 = [UIButton buttonWithType:UIButtonTypeCustom];
//    locationButton2.frame=CGRectMake(0, 0, 40, 40);
//    [locationButton2 setImage:[UIImage imageNamed:@"nav_icon_sousuo_nor"] forState:UIControlStateNormal];
//    [locationButton2 addTarget:self action:@selector(right2Action) forControlEvents:UIControlEventTouchUpInside];
//    self.rightItem2 = locationButton2;
}

-(void)right1Action{
    
    
}

-(void)right2Action{
    
    
}

//2.18,点击行业查看商品类别列表接口
-(void)loadData{
    NSDictionary *paramDic = @{
                               @"tradeId":self.tradeId
                               };
    __weak typeof(self)  weakSelf = self;
    [MBProgressHUD showLoadingGif];
    [Tools AFNetworkingRequestTypePostWithUrl:GETPRODUCTTYPE paramters:paramDic afterResultBlock:^(NSDictionary *resultDic) {
        DLog(@"点击行业查看商品类别列表接口--%@",resultDic);
        if([resultDic[@"flag"] isEqualToString:@"true"]){
            NSArray *data = resultDic[@"data"];
            if([data isKindOfClass:[NSNull class]]){
                [MBProgressHUD dismissHUD];
                return ;
            }
            for(NSDictionary *dic in data){
                MoreGroup *group = [[MoreGroup alloc]init];
                group.tradeName = dic[@"typeName"];
                NSMutableArray *contentArr = [NSMutableArray array];
                NSArray *contents = dic[@"contents"];
                for(NSDictionary *cDic in contents){
                    FurnitureModel *model = [[FurnitureModel alloc]init];
                    model.name = cDic[@"name"];
                    model.id = cDic[@"id"];
                    model.pic = cDic[@"pic"];
                    [contentArr addObject:model];
                }
                group.contents = contentArr;
                [weakSelf.dataSoure addObject:group];
            }
            weakSelf.furniture.dataSoure = weakSelf.dataSoure;
            [MBProgressHUD dismissHUD];
        }else{
            [MBProgressHUD dismissHUD];
            if(resultDic[@"errorString"]){
                [MBProgressHUD showTipMessageInWindow:resultDic[@"errorString"]];
            }
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
